//
//  head1.cpp
//  
//
//  Created by Yun Zhang on 4/1/12.
//  Copyright (c) 2012 Columbia University. All rights reserved.
//

#include <iostream>
#include "head.h"

void start_node::print(){
    cout<<name<<endl;
    if(inc!=NULL)
    inc->print();
    if(prog!=NULL)
    prog->print();
}
void terminal::print(){
    //cout<<name<<endl;

}

void array_func_type::print(){
    cout<<name<<endl;
    if(type!=NULL)
    type->print();
    if(expr_para!=NULL)
    expr_para->print();
}
void unary_stmt::print(){
    cout<<name<<endl;
    
}

void assign_node::print(){
    cout<<name<<endl;
    if(left!=NULL)
    left->print();
    if(right!=NULL)
    right->print();

}

void if_stmt::print(){
    cout<<name<<endl;
    if(condition!=NULL)
    condition->print();
    if(stmt1!=NULL)
    stmt1->print();
    if(stmt2!=NULL)
    stmt2->print();
}

void for_stmt::print(){
    cout<<name<<endl;
    if(left_value!=NULL)
    left_value->print();
    if(expr1!=NULL)
    expr1->print();
    if(expr2!=NULL)
    expr2->print();
    if(stmt!=NULL)
    stmt->print();
    
}

void list::print(){
 //   cout<<"Hello"<<endl;
    cout<<name<<endl;
    cout<<nodelist.size()<<endl;
    for(int i = 0;i<(int)nodelist.size();i++){
        if(nodelist[i]!=NULL)
            nodelist[i]->print();
    }
}
void var_decl::print(){
    cout<<name<<endl;
    if(type!=NULL)
    type->print();
    if(para!=NULL)
    para->print();
}

void const_expr::print(){
    cout<<name<<endl;
    if(left!=NULL)
    left->print();
    if(right!=NULL)
    right->print();
}
void unary_expr::print(){
    cout<<name<<endl;
    if(op!=NULL)
    op->print();
    if(expr!=NULL)
    expr->print();
}
void unary_direct_expr::print(){
    cout<<name<<endl;
    if(unary_expr!=NULL)
    unary_expr->print();
    if(const_expr!=NULL)
    const_expr->print();
}
void para_declaration::print(){
    cout<<name<<endl;
    if(type!=NULL)
    type->print();
    if(terminal!=NULL)
    terminal->print();
    if(expr!=NULL)
    expr->print();
    
}

void func_def::print(){
    cout<<name<<endl;
    if(id!=NULL)
    id->print();
    if(type!=NULL)
    type->print();
    if(para_list!=NULL)
    para_list->print();
    if(stmt!=NULL)
    stmt->print();
}
void func_call::print(){
    cout<<name<<endl;
    if(unary_expr!=NULL)
    unary_expr->print();
    if(parameter_list!=NULL)
    parameter_list->print();
}


















